<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>runnian.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
  
  <body>
    <script type="text/javascript">
    	function testWhile(){
    		var n = prompt("Please input Number:",1);
    		var sum = 0;
    		var seed = 1;							//  种子
    		while(seed<=n){
    			sum += seed;
    			seed++;
    		}
    		alert(sum);
    	}
    	function testContinue(){
    		while(true){							//   is equal for(;;)
    			var year = prompt("请输入要判断是否为闰年的年份：",0);
    			if(0==year) break;
    			if(!/[^0]\d/.test(year)){
    				// 通过正则表达式判断输入年份的合法性,判断是否由数字组成且首位不为0
    				alert("请输入合法的年份！");
    				continue;
    			}
    			year = parseInt(year);
    			var check4 = (0 == year%4);
    			var check100 = (0 == year%100);
    			var check400 = (0 == year%400);
    			//  给出判断结果
    			if((check4&&!check100)||check400) alert(year+"年是闰年.");
    			else alert(year+"年不是闰年.");
    		}
    	}	
    		
    </script>
    <input type="button" onClick="testWhile()" value="TestWhile">
    <input type="button" onClick="testContinue();" value="TestContinue 闰年判断" >
  </body>
</html>
